#include <stdio.h>
#include <string.h>

#define N 100

char str[N];
int a[N][N][3],n;

int main()
{
	scanf("%s",str);
	n = strlen(str);
	for(int i = 0; i < n; i++)  
	{
		for(int j = 0; j < n; j++)
		{
			for(int k = 0; k < 3; k++)
			{
				a[i][j][k] = 0;
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		a[i][i][str[i] - 'a'] = 1;
	}

	for(int k = 1; k < n; k++)
	{ 
		for(int i = 0; i < n - k; i++)
		{
			int j = i + k;     
			for(int t = i;t < j;t++)
			{
                a[i][j][0] += a[i][t][2] * a[t+1][j][0]   //c * a = a  
                            + a[i][t][0] * a[t+1][j][2]   //a * c = a  
                            + a[i][t][1] * a[t+1][j][2];  //b * c = a  

                a[i][j][1] += a[i][t][0] * a[t+1][j][0]   //a * a = b  
                            + a[i][t][0] * a[t+1][j][1]   //a * b = b  
                            + a[i][t][1] * a[t+1][j][1];  //b * b = b  

                a[i][j][2] += a[i][t][1] * a[t+1][j][0]   //b * a = c  
                           + a[i][t][2] * a[t+1][j][1]    //c * b = c  
                           + a[i][t][2] * a[t+1][j][2];   //c * c = c  
            }
        }
    }
    printf("%d\n",a[0][n-1][0]);
    return 0;
}